package MyFunction

import (
	"github.com/gin-gonic/gin"
)

func Hello(context *gin.Context) {
	//context.String(200, "我的第一个项目")

	//进行渲染字符串
	//name := "我是丽丽"
	//context.HTML(200, "Demo01/hello01.html", name)

	//渲染结构体
	//var student Student = Student{
	//	Name: "张三",
	//	Age:  32,
	//}
	//context.HTML(200, "Demo01/hello01.html", student)

	//渲染数组
	/*var Str [3]string = [3]string{"张三", "李四", "王五"}

	for _, value := range Str {
		fmt.Println(value)
	}
	context.HTML(200, "Demo01/hello01.html", Str)*/

	//渲染结构体数组
	/*var Str [3]Student
	Str[0] = Student{
		Name: "张三",
		Age:  32,
	}
	Str[1] = Student{
		Name: "李四",
		Age:  18,
	}
	Str[2] = Student{
		Name: "王五",
		Age:  77,
	}

	context.HTML(200, "Demo01/hello01.html", Str)*/

	//渲染map
	/*var a map[string]string = make(map[string]string, 3)
	a["球拍"] = "乒乓球"
	a["手拍"] = "篮球"
	a["网拍"] = "羽毛球"

	context.HTML(200, "Demo01/hello01.html", a)*/

	//渲染map结构体
	/*var str map[string]Student = make(map[string]Student, 2)
	str["序号1"] = Student{
		Name: "张三",
		Age:  22,
	}
	str["序号2"] = Student{
		Name: "王五",
		Age:  88,
	}

	context.HTML(200, "Demo01/hello01.html", str)*/
	slice := []int{1, 2, 3, 7, 5}
	context.HTML(200, "Demo01/hello01.html", slice)
}

type Student struct {
	Name string
	Age  int
}
